<template>
  <fragment>
    <template v-for="menu in menuList">
      <el-submenu
        v-if="menu.children && menu.children.length > 0"
        :index="menu.path"
        :key="menu.path"
      >
        <template slot="title">
          <i :class="menu.icon"></i>
          <span slot="title">{{ menu.label }}</span>
        </template>
        <menu-item :menuList="menu.children"></menu-item>
      </el-submenu>
      <el-menu-item @click="clickMenu(menu)" v-else :index="menu.path" :key="menu.path">
        <i :class="menu.icon"></i>
        <span slot="title">{{ menu.label }}</span>
      </el-menu-item>
    </template>
  </fragment>
</template>

<script>
import MenuItem from "./MenuItem";
export default {
  name: "MenuItem",
  props: ["menuList"],
  components: { MenuItem },
  methods:{
    clickMenu(item){
      //把当前殿中的节点放到tabs中去
      this.$store.commit('clickMenu',item)
      //2.跳转路由
      this.$router.push({name:item.name})
    }
  }
};
</script>

<style lang="scss" scoped>
</style>